﻿<%@ Page Language="C#" MasterPageFile="~/Front.Master" AutoEventWireup="true" CodeBehind="ManageTask.aspx.cs" Inherits="HRProject.Task.ManageTask" Title="Manage Tasks" %>
<asp:Content ID="IncludePlaceHolder" ContentPlaceHolderID="IncludePlaceHolder" runat="server">
    <link href="/css/task.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="/js/tree.js"></script>
    <script type="text/javascript" src="/js/task.js"></script>
</asp:Content>
<asp:Content ID="TitleIconPlaceHolder" ContentPlaceHolderID="TitleIconPlaceHolder" runat="server">
    <img src="/image/layout/icon/TaskIcon.png" alt="" />
</asp:Content>
<asp:Content ID="TitleNamePlaceHolder" ContentPlaceHolderID="TitleNamePlaceHolder" runat="server">
    Tasks
</asp:Content>
<asp:Content ID="MainPanelPlaceHolder" ContentPlaceHolderID="MainPanelPlaceHolder" runat="server">
    
        Select month:
        <input type="button" value="&lt;" onclick="previousMonth();"/>
        <input type="text" name="month" value="<%= Month %>" class="dateInput"/>
        <input type="hidden" id="hdfMonth" value="<%= Month %>"/>
        <input type="hidden" id="hdfYear" value="<%= Year %>"/>
        <input type="button" value="&gt;" onclick="nextMonth();"/>
        year: 
        <input type="button" value="&lt;&lt;" onclick="previousYear();"/>
        <input type="text" name="year" value="<%= Year %>" class="dateInput"/>
        <input type="button" value="&gt;&gt;" onclick="nextYear();"/>
        <input type="button" id="btnViewMonth" value="Select" onclick="selectMonth();"/>
        <input type="button" value="Add task" onclick="addTask(this);"/>
        <div class="calendar">
		    <div class="board">
		    <%
                DateTime firstDateOfMonth = new DateTime(Year,Month,1);
                string temp = "";
                while (!firstDateOfMonth.DayOfWeek.Equals(DayOfWeek.Monday))
                {
                    firstDateOfMonth = firstDateOfMonth.AddDays(-1);
                    temp = "<div class=\"date\">" + firstDateOfMonth.ToString("dd/MM") + "</div>" + temp;
                }
		        %><%= temp %><%
                int month = DateTime.DaysInMonth(Year, Month);
                for (int i = 0; i < month; i++)
                {
                    %><div class="date inmonth"><%= new DateTime(Year, Month, i+1).ToString("dd/MM")%></div><%
                }
                DateTime endDateOfMonth = new DateTime(Year, Month, DateTime.DaysInMonth(Year, Month));
                while (!endDateOfMonth.DayOfWeek.Equals(DayOfWeek.Sunday))
                {
                    endDateOfMonth = endDateOfMonth.AddDays(1);
                    %><div class="date"><%= endDateOfMonth.ToString("dd/MM")%></div><%
                }
            %>
		    </div>
		    <div class="tasks">
		    <%
                long numberOfWeek = Convert.ToInt64((endDateOfMonth - firstDateOfMonth).TotalDays / 7);      
                for (int i = 0; i < Tasks.Count; i++)
                {
                    TimeSpan pre = Tasks[i].EstimateStartDate.Subtract(firstDateOfMonth);
                    long left = Convert.ToInt64(pre.TotalDays%7) * 122;
                    long top = Convert.ToInt64(Math.Floor(pre.TotalDays/7)) * 52;
                    TimeSpan duration = Tasks[i].EstimateFinishDate.Subtract(Tasks[i].EstimateStartDate);
                    long width = Convert.ToInt64(duration.TotalDays * 122);
                    string color = System.Drawing.ColorTranslator.ToHtml(Tasks[i].DisplayColor);
                    %><div class="task" style="left:<%= left %>px;top:<%= top %>px;width:<%= width %>px;background-color:<%= color %>"
                        onmousemove="moveOnTask(this, event);treeNodeMove(this);" onmouseup="upOnTask(this, event);"
                        onmouseout="outOfTask(this, event);treeNodeOut(this);">
                        <%= Tasks[i].Name %>
                        <div class="actionbar">
                            <div class="item edit"  onclick="editTask(this);"></div>
                            <div class="item remove" onclick="removeTask(this);"></div>
                            <input type="hidden" name="id" value="<%= Tasks[i].Id %>"/>
                        </div>
                      </div><%
                }
		    %>
		    </div>
	    </div>
	
</asp:Content>
